package com.yanqu.road.server.logic.recharge;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.config.goods.MallInfo;
import com.yanqu.road.entity.enums.eMailType;
import com.yanqu.road.entity.recharge.RechargeOrder;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.ActivityMallModule;
import com.yanqu.road.server.logic.mail.MailManager;
import com.yanqu.road.server.manger.MultipleLanguageMgr;
import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.property.PropertyHelper;

/**
 * 代金币礼包
 */
public class GoldTokenRecharge extends BaseRecharge {

    public GoldTokenRecharge(GamePlayer player, MallInfo mallInfo, ActivityInfo activityInfo) {
        super(player, mallInfo, activityInfo);
    }

    @Override
    protected boolean isRepeatedBuy(String orderNo) {
        return player.getModule(ActivityMallModule.class).isOverLimitBuyCount(mallInfo, 1);
    }

    @Override
    protected void repeatedBuyLogic() {

    }

    @Override
    protected String addMall(String orderNo, RechargeOrder rechargeOrder) {
        if(null == mallInfo){
            logger.error("GoldTokenRecharge add mall fail,mallInfo is null,orderNo:{}", orderNo);
            return "";
        }
        Property mailReward = PropertyHelper.parseStringToProperty(mallInfo.getReward());
        String mailTitle = MultipleLanguageMgr.getContent(MailManager.GOLD_TOKEN_RECHARGE_TITLE, player.getLanguage());
        String mailContent = MultipleLanguageMgr.getContent(MailManager.GOLD_TOKEN_RECHARGE_CONTENT, player.getLanguage());
        MailManager.sendMail(player.getUserId(), eMailType.SYSTEM.getValue(), PropertyHelper.parsePropertyToString(mailReward),
                mailContent, mailTitle);
        return mallInfo.getReward();
    }

}
